//
//  LabelAndTextFieldTableViewCell.m
//  GeniusHelp_OC
//
//  Created by 8b410-2 on 16/10/20.
//  Copyright © 2016年 8b410-2. All rights reserved.
//

#import "LabelAndTextFieldTableViewCell.h"
#import "UILabel+Common.h"
@interface LabelAndTextFieldTableViewCell ()
@property (strong,nonatomic)UILabel *label;

@end

@implementation LabelAndTextFieldTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _label = [UILabel labelWithSystemFontSize:16 textColor:[UIColor blackColor]];
        [self addSubview:_label];
        
        _textField = [[UITextField alloc] init];
        [self addSubview:_textField];
        
        _label.translatesAutoresizingMaskIntoConstraints = NO;
        _textField.translatesAutoresizingMaskIntoConstraints = NO;
        
        NSMutableArray *cons = [[NSMutableArray alloc] init];
        NSDictionary *viewDict = @{@"label":_label,@"textField":_textField};
        [cons addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[label]|" options:NSLayoutFormatAlignAllCenterY metrics:nil views:viewDict]];
        [cons addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-20-[label]-5-[textField]-10-|" options:0 metrics:nil views:viewDict]];
        [cons addObjectsFromArray:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-10-[textField]-10-|" options:0 metrics:nil views:viewDict]];
        [self addConstraints:cons];
        [self setBackgroundColor:[UIColor whiteColor]];
    }
    return self;
}


- (void)setTitle:(NSString *)title {
    _title = title;
    _label.text = [NSString stringWithFormat:@"%@ :",title];
    _textField.placeholder = [NSString stringWithFormat:@"请输入%@",title];
}
@end
